package com.wfit.controller.app;

import com.wfit.result.Result;
import com.wfit.service.OrderService;
import com.wfit.dto.OrderDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/order")
public class AppOrderController {
@Autowired
private OrderService orderService;

    @PostMapping("/generator")
    public Result generator(@RequestBody OrderDTO dto) {
        Result result = orderService.generatorOrder(dto);
        return result;
    }
    @GetMapping("/list")
    public Result list(String dataType) {
        Result result = orderService.getUserList(dataType);
        return result;
    }
    @GetMapping("/one/{orderId}")
    public Result getOrderOne(@PathVariable String orderId) {
        Result result = orderService.getOrderOne(orderId);
        return result;
    }
    @PutMapping("/update/{status}/{orderId}")
    public Result updateOrderStatus(@PathVariable String status,@PathVariable String orderId) {
        Result result = orderService.updateOrderStatus(status, orderId);
        return result;
    }
    @PutMapping("/cancel/{orderId}")
    public Result updateOrderStatus(@PathVariable String orderId) {
        Result result = orderService.cancelOrder(orderId);
        return result;
    }

}
